home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_5.lha / 8_5 / fwrite.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  714b  |  30 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / write out num objects of the given
  6. / size from the named buffer
  7. nt fwrite(void *vbuf, unsigned int size,
  8.    unsigned int num, FILE *f)
  9.  
  10.    char *buf = (char*)vbuf;
  11.    if (f->mode != input)
  12. {
  13. // read in num * size bytes
  14. for (unsigned int n = num; n-- > 0; )
  15.     for (unsigned int s = size; s-- > 0; )
  16.     if (!f->out->put(*buf++))
  17.         // The end of the output
  18.         // partway through an object.
  19.         // Return the number of complete
  20.         // objects written so far.
  21.         return num - n;
  22.  
  23. // Return the number of
  24. // complete objects written
  25. return num - n;
  26. }
  27.  
  28.    return 0;
  29.  
  30.